//
//  WWCartoonTableCell.m
//  YiQiTingShu
//
//  Created by WeiWei on 15/11/11.
//  Copyright © 2015年 直到世界的尽头. All rights reserved.
//

#import "WWCartoonTableCell.h"
#import <UIImageView+WebCache.h>
#import "PublicHeader.h"

@interface WWCartoonTableCell ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIImageView *cartoonImageView;

@end

@implementation WWCartoonTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _cartoonImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_cartoonImageView];
        _titleLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_titleLabel];
        [self.titleLabel NightWithType:UIViewColorTypeNormal];
        [self.contentView NightWithType:UIViewColorTypeNormal];
    }
    return self;
}

- (void)setModel:(WWCartoonModel *)model {
    
    if (_model != model) {
        _model = model;
    }
    self.titleLabel.text = model.title;
    self.titleLabel.textColor = [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:1];
    [self.cartoonImageView sd_setImageWithURL:[NSURL URLWithString:model.coverImage] placeholderImage:[UIImage imageNamed:@"placeholderCh_Larger.png"]];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.cartoonImageView.frame = CGRectMake(0, FitConstant_YorHeight(35), FitConstant_XorWidth(375), FitConstant_YorHeight(180));
    
    self.titleLabel.frame = CGRectMake(FitConstant_XorWidth(5), FitConstant_YorHeight(5), FitConstant_XorWidth(370), FitConstant_YorHeight(17));
}

@end
